package br.com.cqipac.dao;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import br.com.cqipac.ejb.FacadeIpacRemote;

public class DaoFactory {

	private static InitialContext jndiContext = null;

	public static RemoteDao getDao(String daoName)
	/*throws javax.naming.NamingException*/{

		RemoteDao remoteDao = null;

		try {

			if (jndiContext == null) {
				jndiContext = new javax.naming.InitialContext();
			}
			
			remoteDao = (RemoteDao) jndiContext.lookup("CQIpacEAR/"+daoName+"/remote");
			//facadeIpacRemote = (FacadeIpacRemote) PortableRemoteObject.narrow(ref, FacadeIpacRemote.class);


		} catch (NamingException e) {
			// TODO Auto-generated catch block

		}

		return remoteDao;
	}

}
